#ifndef PCLVIEWER_H
#define PCLVIEWER_H

#include <iostream>

// Qt
#include <QMainWindow>
#include <QFileDialog>
#include <QTextCodec>
#include <QString>

// Point Cloud Library
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/io/pcd_io.h>
#include <pcl/search/search.h>
#include <pcl/search/kdtree.h>
#include <pcl/features/normal_3d.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/filters/passthrough.h>
#include <pcl/segmentation/region_growing.h>
#include <pcl/common/transforms.h>


// Visualization Toolkit (VTK)
#include <vtk-7.0/vtkRenderWindow.h>

#include "workthread/workthread.h"


typedef pcl::PointXYZRGBA PointT;
typedef pcl::PointCloud<PointT> PointCloudT;

namespace Ui
{
  class PCLViewer;
}

class PCLViewer : public QMainWindow
{
  Q_OBJECT

public:
  explicit PCLViewer (QWidget *parent = 0);
  ~PCLViewer ();

    std::string cloudFileName;
    std::string currentPrimitive;
    std::string currentAssocitive;



    //show
    void show3DResults(std::string primitive,std::string associtive);
    void showBasicCloud();

    //work function
    workThread *workthread;
public slots:

protected:
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
  PointCloudT::Ptr cloud;


private slots:
  void on_openButton_clicked();

  void on_saveButton_clicked();


  void on_segmentButton_clicked();


  void on_OKPushButton_clicked();


  void on_computePushButton_clicked();

  void showIt(int it);


  void on_OKShowSectionPushButton_clicked();

  void on_showLogPushButton_clicked();

private:
  Ui::PCLViewer *ui;
  void keyPressEvent(QKeyEvent *event);
  void showTheSelectedItem();
  void showLog(std::string dir);
};

#endif // PCLVIEWER_H
